﻿using ManYan.Common.DomainInterface;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ManYan.EFCore
{
    public class EfRepository : IRepository
    {
        private readonly WechatDbContext _db;
        public EfRepository(WechatDbContext db)
        {
            _db = db;
        }

        public void BeginTran()
        {
            _db.Database.BeginTransaction();
        }

        public void Commit()
        {
            _db.SaveChanges();
            _db.Database.CommitTransaction();
        }

        public void Dispose()
        {
            _db.Dispose();
            GC.Collect();
        }

        public void RollbackTran()
        {
            _db.Database.RollbackTransaction();
        }
    }
}
